Page({
    data: {
    icon: 'https://www.kunquer.com/favicon.ico',
    select_index: 0,
    list: []
    },
    onReady() {
        wx.createSelectorQuery().selectAll('.index-name').boundingClientRect(results => {
        results.forEach(rect => {
        let key = 'list['+rect.dataset.id+'].top';       
        this.setData({[key]: rect.top});        
        });       
        }).exec();      
    },
    selectIndex(e) {     
        this.setData({select_index: e.currentTarget.dataset.index});     
    },
    scroll(e) {
        this.data.list.some((v, k) => { 
            if(v.top <= e.detail.scrollTop) {      
                if(this.data.list[k+1] && this.data.list[k+1].top > e.detail.scrollTop) {   
                    this.setData({select_index: k});    
                    return true;   
                }  
            }
        })  
    },
    onLoad(options){
        let list = [];
        for(let i = 0; i < 20; i++) {
        list.push({
        name: i,
        items: Array.from(Array(9), (v, k) => '鲲圭云计算')
        });
        }   
        console.log(list);  
        this.setData({list: list});       
        },      
    })
   